#include "PauseDialog.h"
#include "Constants.h"
#include "EventManager.h"

PauseDialog::PauseDialog(ds::WorldLayer layer) : ds::UIDialog(layer,"PauseDialog","TextureArrayMaterial",ds::Vec2(0,0)) {

	int sx = QUIT_DLG_X;
	int sy = QUIT_DLG_Y;

	// background
	addImage(40,ds::Rect(0,750,230,150),ds::Vec2( sx , sy));	
	addImage(41,ds::Rect(0,750,230,150),ds::Vec2( sx + 230,sy));	
	
	int by = QUIT_DLG_Y + 100;
	// both buttons
	addImageButton(44,ds::Rect(250,0,150,40), ds::Vec2(sx + 8,by));
	addImageButton(45,ds::Rect(250,150,150,40),ds::Vec2(sx + 290,by));	

	// text
	addImage(46,ds::Rect(360,550,460,26),ds::Vec2( sx , sy ));		
	addImage(47,ds::Rect(450,550,216,26),ds::Vec2( sx+122 , sy +50 ));		

	//	
	registerListener(this);
	setMouseOffset(ds::Vec2(-15,-15));
	deactivate();
}

void PauseDialog::onUIEvent(const ds::IUIEvent& event) {
	if ( event.getEventType() == ds::UI_EVENT_BUTTON_CLICKED ) {
		if (event.getControlID() == 45 ) {			
			FIRE_EMPTY_EVENT(EVN_CONTINUE_GAME);
		}			
		else if ( event.getControlID() == 44 ) {
			FIRE_EMPTY_EVENT(EVN_QUIT_GAME);
		}					
	}
}
